package models

import (
	"restaurant-system/config"
)

func AutoMigrate() {
	// 禁用外键检查，以便清理数据
	config.DB.Exec("SET FOREIGN_KEY_CHECKS = 0")

	config.DB.AutoMigrate(
		&User{},
		&Dish{},
		&Order{},
		&OrderItem{},
		&Review{},
		&PointRecord{},
		&PointRule{},
		&CouponTemplate{},
		&UserCoupon{},
		&CartItem{},
		&Table{},
		&TableReservation{},
		&Payment{},
		&Refund{},
		&Store{},
		&DeliveryAddress{},
		&Delivery{},
		&UserPreference{},
		&UserFavorite{},
		&BrowsingHistory{},
		&OrderStats{},
		&ChatSession{},
		&ChatMessage{},
		&Notification{},
		&AIServiceConfig{},
		&AIQARule{},
	)

	// 重新启用外键检查
	config.DB.Exec("SET FOREIGN_KEY_CHECKS = 1")
}
